from matplotlib import pyplot as plt

# 绘制二维矩形
def Rectangle_2D(ax, xy, width, height, fill = True, facecolor = 'grey', alpha = 0.5):
    """
          :                +------------------+
          :                |                  |
          :              height               |
          :                |                  |
          :               (xy)---- width -----+

    :param ax: 绘图对象
    :param xy: 下顶点 (x,y) （元组）
    :param width: 宽
    :param height: 高
    :param fill : 填充
    :param facecolor: 填充颜色
    :param alpha: 不透明度
    :return: None
    """
    object = plt.Rectangle(xy, width, height, fill=fill, color=facecolor, alpha=alpha)
    # object = plt.Rectangle(xy, width, height, fill=fill, color=facecolor, alpha=alpha, edgecolor='blue', linestyle='dashed')
    ax.add_patch(object)

# 绘制圆形
def Circle_2D(ax, center, radius, fill = True, facecolor = 'grey', alpha = 0.5):
    """
              :              +
              :              |
              :              radius
              :              |
              :            (xy)——radius——+


        :param ax: 绘图对象
        :param xy: 圆心 （元组）
        :param radius: 半径
        :param fill : 填充
        :param facecolor: 填充颜色
        :param alpha: 不透明度
        :return: None
        """

    object = plt.Circle(center, radius, color=facecolor, fill=fill, alpha=alpha)
    # object = plt.Circle(center, radius, fill=False, alpha=alpha, edgecolor='red', linestyle='solid')
    ax.add_patch(object)